import {
	ref,
	onMounted
} from 'vue'
import {
	ElMessage,
	ElMessageBox
} from 'element-plus'

export function useMouse() {

	//弹窗确认框
	function confirmMessage(content, callBack = () => {}) {
		ElMessageBox.confirm(
				content,
				'提示', {
					confirmButtonText: '确认',
					cancelButtonText: '取消',
					type: 'warning',
				}
			)
			.then(() => {
				//成功操作
				callBack();
			})
			.catch(() => {

			})
	}

	//会员弹窗确认框
	function confirmMessageMember(content, callBack = () => {}) {
		ElMessageBox.confirm(
				content,
				'提示', {
					confirmButtonText: '会员权益',
					cancelButtonText: '我在想想',
					type: 'warning',
				}
			)
			.then(() => {
				//成功操作
				callBack();
			})
			.catch(() => {

			})
	}

	//提示消息
	function hintMessage(content) {
		ElMessage({
			message: content,
			duration: 2000,
			grouping: true, //合并相同消息
		})
	}

	//警告消息
	function warningMessage(content) {
		ElMessage({
			message: content,
			duration: 2000,
			type: 'warning',
			grouping: true, //合并相同消息
		})
	}

	//提交内容
	function promptMessage(content, callBack = () => {}) {
		ElMessageBox.prompt(content, '提示', {
				confirmButtonText: '确认',
				cancelButtonText: '取消',
			})
			.then(({
				value
			}) => {
				console.log(value)
				//成功操作
				callBack(value);
			})
			.catch(() => {

			})
	}

	return {
		confirmMessage,
		confirmMessageMember,
		hintMessage,
		promptMessage,
		warningMessage
	}

}

//弹窗确认框
export const confirmMessage = (content, callBack = () => {}) => {
	ElMessageBox.confirm(
			content,
			'提示', {
				confirmButtonText: '确认',
				cancelButtonText: '取消',
				type: 'warning',
			}
		)
		.then(() => {
			//成功操作
			callBack();
		})
		.catch(() => {

		})
}

//会员弹窗确认框
export const confirmMessageMember = (content, callBack = () => {}) => {
	ElMessageBox.confirm(
			content,
			'提示', {
				confirmButtonText: '会员权益',
				cancelButtonText: '我在想想',
				type: 'warning',
			}
		)
		.then(() => {
			//成功操作
			callBack();
		})
		.catch(() => {

		})
}

//提示消息
export const hintMessage = (content) => {
	ElMessage({
		message: content,
		duration: 2000,
		grouping: true, //合并相同消息
	})
}

//警告消息
export const warningMessage = (content) => {
	ElMessage({
		message: content,
		duration: 2000,
		type: 'warning',
		grouping: true, //合并相同消息
	})
}

//提交内容
export const promptMessage = (content, callBack = () => {}) => {
	ElMessageBox.prompt(content, '提示', {
			confirmButtonText: '确认',
			cancelButtonText: '取消',
		})
		.then(({
			value
		}) => {
			console.log(value)
			//成功操作
			callBack(value);
		})
		.catch(() => {

		})
}